import http from "@/api";
import qs from "qs";
//获取流程刘表
export const getProcessList = params => {
  return http.post(
    "/pages/jbpm!findPageProcessDefinitions.action",
    qs.stringify({
      _search: false,
      rows: params.pageSize,
      page: params.pageNum,
      sidx: "key",
      sord: "desc"
    })
  );
};
//获取流程实例列表
export const getProcessInstanceList = params => {
  return http.post(
    "/pages/jbpm!findPageProcessInstance.action?processHistoriesQueryDTO.processDefinitionId=" + params.processDefinitionId,
    qs.stringify({
      _search: false,
      rows: params.pageSize,
      page: params.pageNum,
      sidx: "id",
      sord: "desc"
    })
  );
};
//查看流程实例
export const getProcessInstance = params => {
  return http.post("/pages/jbpm!getActivityCoordinates.action?pid=" + params);
};
//查看流程图
export const getProcessImg = params => {
  return http.post("/pages/jbpm!getProcessImage.action?processDefinitionId=" + params);
};
//查看流程节点
export const getFlowProperty = params => {
  return http.post("/pages/flowProperty!findFlowPropertyByProcessDefinitionId.action", qs.stringify(params));
};
//获取工单状态
export const getStatus = params => {
  return http.post("/pages/dataDictionaryItems!findByCode.action", qs.stringify(params));
};
//获取通知模板列表
export const getNoticeRuleList = params => {
  return http.post(
    "/pages/noticeRule!findPager.action",
    qs.stringify({
      "noticeRuleDTO.noticeRuleNo": "request",
      _search: false,
      rows: params.pageSize,
      page: params.pageNum,
      sidx: "noticeRuleId",
      sord: "desc"
    })
  );
};
//获取规则b包列表
export const getRulePackageList = params => {
  return http.post(
    "/pages/rulePackage!findRulePackageByPage.action",
    qs.stringify({
      "rulePackageDto.flagName": "requestProce",
      _search: false,
      rows: params.pageSize,
      page: params.pageNum,
      sidx: "rulePackageNo",
      sord: "desc"
    })
  );
};
//获取节点流程属性
export const getAttribute = params => {
  return http.post("/pages/flowProperty!findFlowActivityById.action", qs.stringify(params));
};
//保存节点属性
export const saveFlowActive = (noticeRuleId, noticeRule, taskActions, params) => {
  return http.post(
    "/pages/flowProperty!updateFlowActivity.action?" + noticeRuleId + "&" + noticeRule + "&" + taskActions,
    qs.stringify(params)
  );
};
//部署流程，上传文件
export const uploadFileProcess = params => {
  return http.post("/pages/jbpm!deployProcessDefinitionXmlFile.action", qs.stringify(params));
};
//删除流程
export const deleteProblemClass = params => {
  return http.post("/pages/jbpm!unDeployProcessDefinition.action", qs.stringify(params));
};
//流程选项
//已设置流程选项
export const processUseList = params => {
  return http.post("/pages/processUse!processUseByUseName.action", qs.stringify(params));
};
//设置流程选项
export const setProcessOption = params => {
  return http.post("/pages/processUse!processUseSet.action", qs.stringify(params));
};
